// 写一个小程序常用的请求文件
let baseUrl = 'http://localhost:8080';
const post = (url, data) => {
    return new Promise((resolve, reject) => {
        wx.request({
            url: baseUrl + url,
            method: 'POST',
            data,
            success(res) {
                resolve(res.data);
            },
            fail(err) {
                reject(err);
                wx.showToast({
                    title: '网络错误',
                    icon: 'error'
                })
            },
        })
    })
}
const postParams = (url, data) => {
    return new Promise((resolve, reject) => {
        wx.request({
            url: baseUrl + url,
            method: 'POST',
            data,
            success(res) {
                resolve(res.data);
            },
            fail(err) {
                reject(err);
                wx.showToast({
                    title: '网络错误',
                    icon: 'error'
                })
            },
        })
    })
}

export { post, postParams };